package org.cfg;

import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import com.google.common.collect.Range;
import org.apache.commons.lang3.ArrayUtils;
import java.util.HashMap;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import com.google.common.collect.Maps;
import com.xiaoleilu.hutool.util.RandomUtil;
import java.util.ArrayList;
import com.sojoys.artifact.build.data.base.BaseCfg;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.collect.TreeRangeMap;
import com.sojoys.artifact.tools.ToolMap;
import java.util.TreeMap;
import com.sojoys.artifact.tools.ToolCopy;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 精灵（看板娘）
 */
public class RoleCfg extends BaseCfg<RoleCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "role";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.RoleCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 14;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","排序","是否开启","初始好感","好感等级","年龄","生日","星座","身高","礼品","爱好","时装","默认时装","心情值更新",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","order","isOpen","favor","favorLevels","age","birthday","constellation","height","gift","hobby","dress","roleModel","moodChange",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","order","isOpen","favor","favorLevels","age","birthday","constellation","height","gift","hobby","dress","roleModel","moodChange",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,106006350,-1180237164,97205822,1528682829,96511,1069376125,-2084080173,-1221029593,3172656,99450322,95849015,319251539,2042553735,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","boolean","int","int[]","int","String","String","String","Map","Map","int[]","int","List",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Boolean.class,Integer.class,int[].class,Integer.class,String.class,String.class,String.class,Map.class,Map.class,int[].class,Integer.class,List.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 排序
	 */
	private int order;
	
	/**
	 * 是否开启
	 */
	private boolean isOpen;
	
	/**
	 * 初始好感
	 */
	private int favor;
	
	/**
	 * 好感等级
	 */
	private int[] favorLevels;
	
	/**
	 * 年龄
	 */
	private int age;
	
	/**
	 * 生日
	 */
	private String birthday;
	
	/**
	 * 星座
	 */
	private String constellation;
	
	/**
	 * 身高
	 */
	private String height;
	
	/**
	 * 礼品
	 */
	private Map gift;
	
	/**
	 * 爱好
	 */
	private Map hobby;
	
	/**
	 * 时装
	 */
	private int[] dress;
	
	/**
	 * 默认时装
	 */
	private int roleModel;
	
	/**
	 * 心情值更新
	 */
	private List moodChange;
	
	
	
	public static RoleCfg builder() {
		RoleCfg roleCfg = new RoleCfg();
		return roleCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 排序
	 */
	public int getOrder() {
		return order;
	}
	
	/**
	 * 是否开启
	 */
	public boolean getIsOpen() {
		return isOpen;
	}
	
	/**
	 * 初始好感
	 */
	public int getFavor() {
		return favor;
	}
	
	/**
	 * 好感等级
	 */
	public int[] getFavorLevels() {
		return favorLevels;
	}
	
	/**
	 * 年龄
	 */
	public int getAge() {
		return age;
	}
	
	/**
	 * 生日
	 */
	public String getBirthday() {
		return birthday;
	}
	
	/**
	 * 星座
	 */
	public String getConstellation() {
		return constellation;
	}
	
	/**
	 * 身高
	 */
	public String getHeight() {
		return height;
	}
	
	/**
	 * 礼品
	 */
	public Map getGift() {
		return gift;
	}
	
	/**
	 * 爱好
	 */
	public Map getHobby() {
		return hobby;
	}
	
	/**
	 * 时装
	 */
	public int[] getDress() {
		return dress;
	}
	
	/**
	 * 默认时装
	 */
	public int getRoleModel() {
		return roleModel;
	}
	
	/**
	 * 心情值更新
	 */
	public List getMoodChange() {
		return moodChange;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.order;
        values[2] = this.isOpen;
        values[3] = this.favor;
        values[4] = this.favorLevels;
        values[5] = this.age;
        values[6] = this.birthday;
        values[7] = this.constellation;
        values[8] = this.height;
        values[9] = this.gift;
        values[10] = this.hobby;
        values[11] = this.dress;
        values[12] = this.roleModel;
        values[13] = this.moodChange;
        return values;
	}
	
	protected RoleCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.order = (int)vals[1];
		this.isOpen = (boolean)vals[2];
		this.favor = (int)vals[3];
		this.favorLevels = (int[])vals[4];
		this.age = (int)vals[5];
		this.birthday = (String)vals[6];
		this.constellation = (String)vals[7];
		this.height = (String)vals[8];
		this.gift = (Map)vals[9];
		this.hobby = (Map)vals[10];
		this.dress = (int[])vals[11];
		this.roleModel = (int)vals[12];
		this.moodChange = (List)vals[13];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.order);
        map.put(keys[2], this.isOpen);
        map.put(keys[3], this.favor);
        map.put(keys[4], this.favorLevels);
        map.put(keys[5], this.age);
        map.put(keys[6], this.birthday);
        map.put(keys[7], this.constellation);
        map.put(keys[8], this.height);
        map.put(keys[9], this.gift);
        map.put(keys[10], this.hobby);
        map.put(keys[11], this.dress);
        map.put(keys[12], this.roleModel);
        map.put(keys[13], this.moodChange);
        return map;
    }
    
    protected RoleCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.order = (int)map.get(keys[1]);
   		this.isOpen = (boolean)map.get(keys[2]);
   		this.favor = (int)map.get(keys[3]);
   		this.favorLevels = (int[])map.get(keys[4]);
   		this.age = (int)map.get(keys[5]);
   		this.birthday = (String)map.get(keys[6]);
   		this.constellation = (String)map.get(keys[7]);
   		this.height = (String)map.get(keys[8]);
   		this.gift = (Map)map.get(keys[9]);
   		this.hobby = (Map)map.get(keys[10]);
   		this.dress = (int[])map.get(keys[11]);
   		this.roleModel = (int)map.get(keys[12]);
   		this.moodChange = (List)map.get(keys[13]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.order);
        obj.put(keys[2], this.isOpen);
        obj.put(keys[3], this.favor);
        obj.put(keys[4], this.favorLevels);
        obj.put(keys[5], this.age);
        obj.put(keys[6], this.birthday);
        obj.put(keys[7], this.constellation);
        obj.put(keys[8], this.height);
        obj.put(keys[9], this.gift);
        obj.put(keys[10], this.hobby);
        obj.put(keys[11], this.dress);
        obj.put(keys[12], this.roleModel);
        obj.put(keys[13], this.moodChange);
        return obj;
    }
    
    protected RoleCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.order = obj.getIntValue(keys[1]);
	    this.isOpen = obj.getBooleanValue(keys[2]);
	    this.favor = obj.getIntValue(keys[3]);
		this.favorLevels = obj.getObject(keys[4],int[].class);
	    this.age = obj.getIntValue(keys[5]);
	    this.birthday = obj.getString(keys[6]);
	    this.constellation = obj.getString(keys[7]);
	    this.height = obj.getString(keys[8]);
		this.gift = obj.getObject(keys[9],Map.class);
		this.hobby = obj.getObject(keys[10],Map.class);
		this.dress = obj.getObject(keys[11],int[].class);
	    this.roleModel = obj.getIntValue(keys[12]);
		this.moodChange = obj.getObject(keys[13],List.class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.order);
	    byteBuf.writeBoolean(this.isOpen);
	    byteBuf.writeInt(this.favor);
	    byteBuf.writeObject(this.favorLevels);
	    byteBuf.writeInt(this.age);
	    byteBuf.writeString(this.birthday);
	    byteBuf.writeString(this.constellation);
	    byteBuf.writeString(this.height);
	    byteBuf.writeObject(this.gift);
	    byteBuf.writeObject(this.hobby);
	    byteBuf.writeObject(this.dress);
	    byteBuf.writeInt(this.roleModel);
	    byteBuf.writeObject(this.moodChange);
    }
	
	protected RoleCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.order = byteBuf.readInt(null);
	    this.isOpen = byteBuf.readBoolean(null);
	    this.favor = byteBuf.readInt(null);
	    this.favorLevels = byteBuf.readIntArray(null);
	    this.age = byteBuf.readInt(null);
	    this.birthday = byteBuf.readString(null);
	    this.constellation = byteBuf.readString(null);
	    this.height = byteBuf.readString(null);
	    this.gift = (Map)byteBuf.readObject();
	    this.hobby = (Map)byteBuf.readObject();
	    this.dress = byteBuf.readIntArray(null);
	    this.roleModel = byteBuf.readInt(null);
	    this.moodChange = (List)byteBuf.readObject();
	    return this;
	}
	
	public RoleCfg deepCopy(){
		RoleCfg roleCfg = null;
		try {
			roleCfg = (RoleCfg) super.clone();
		    roleCfg.favorLevels = ToolCopy.copyObject(this.favorLevels);
		    roleCfg.gift = ToolCopy.copyObject(this.gift);
		    roleCfg.hobby = ToolCopy.copyObject(this.hobby);
		    roleCfg.dress = ToolCopy.copyObject(this.dress);
		    roleCfg.moodChange = ToolCopy.copyObject(this.moodChange);
			return roleCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return roleCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
